package com.adou.common.util;

import com.adou.shiro.token.TokenManager;

import java.io.Serializable;

public class EntityUtil {

    public static Entity success() {
        return new Entity(1, "操作成功", TokenManager.getSessionIdByKey(), null);
    }

    public static Entity error() {
        return new Entity(500, "操作失败", TokenManager.getSessionIdByKey(), null);
    }

    public static Entity success(Object data) {
        return new Entity(1, "操作成功", TokenManager.getSessionIdByKey(), data);
    }

    public static Entity error(int result, String msg) {
        return new Entity(result, msg, TokenManager.getSessionIdByKey(), null);
    }

    public static class Entity implements Serializable {

        private int result;
        private String msg;
        private String sessionid;
        private Object data;

        public Entity(int result, String msg, String sessionid, Object data) {
            this.result = result;
            this.msg = msg;
            this.sessionid = sessionid;
            this.data = data;
        }

        public int getResult() {
            return result;
        }

        public void setResult(int result) {
            this.result = result;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        public String getSessionid() {
            return sessionid;
        }

        public void setSessionid(String sessionid) {
            this.sessionid = sessionid;
        }

        public Object getData() {
            return data;
        }

        public void setData(Object data) {
            this.data = data;
        }

    }

}
